package demo_09_29_08;

/**
 * @author:连志鹏
 * @className:work_01
 * @descrption:
 * @date: 2021/9/29 16:16
 * @version: 0.1
 * @since: 1.8
 */
public class work_01 {
    public static void main(String[] args) {
        System.out.println(hammingWeight(128));

    }
    public static int hammingWeight(int n) {

        int ret = 0;
     String num =   Integer.toBinaryString(n);

     String[] str = num.split("");
        for (int i = 0; i < str.length; i++) {
            if(str[i].equals("1"))
                ret++;
        }
     return ret;
    }

}
